package com.seele.base.models;

import android.support.annotation.NonNull;

public class PingModel  implements  Comparable<PingModel>{

    public String ping;//ping 文字

    public int count;//ping 的次数

    public int size;//发送数据包的大小

    public int time;//发送数据包间隔的时间


    public String ip;//请求的地址

    public String result;// 请求的结果

    public String lost;//丢包率

    public int delay;//延迟

    public boolean isAvailable;//地址是否正确


    public String getPing() {
        if (count == 0) {
            count = 2;
        }

        if (size == 0) {
            size = 64;
        }
        if (time == 0) {
            time = 1;
        }
        String countCmd = " -c " + count + " ";
        String sizeCmd = " -s " + size + " ";
        String timeCmd = " -i " + time + " ";
        String ip_adress = ip;

        return "ping" + countCmd + timeCmd + sizeCmd + ip_adress;
    }

    public int getCount() {
        return count;
    }

    public int getSize() {
        return size;
    }

    public int getTime() {
        return time;
    }

    public String getIp() {
        return ip;
    }

    public String getResult() {
        return result;
    }

    public String getLost() {
        return lost;
    }

    public int getDelay() {
        return delay;
    }

    public boolean isAvailable() {
        return isAvailable;
    }


    @Override
    public String toString() {
        return super.toString();
    }

    @Override
    public int compareTo(@NonNull PingModel model) {
        if (this.delay < model.delay)
            return -1;
        else if (this.delay > model.delay)
            return 1;
        else
            return 0;
    }
}
